package com.example.demo.batis;

import com.example.demo.control.UserBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface User1Mapper {
    @Select("select * from user")
    public List<UserBean> selectAll();

    @Select("select * from user where id = #{id} limit 1")
    public UserBean selectById(int id);

    @Insert("insert into user (name,pd) values (#{name},#{pd})")
    public boolean insert(UserBean id);

    /**
     * 如何返回添加的id
     * @param id
     * @return
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into user (name,pd) select #{name},#{pd} from dual")
    public int insert2(UserBean id);

    @Insert("update  user set pd =${pd} where id = #{id}")
    public int update2(UserBean id);

}